﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;


namespace WindowsPhoneApplication1
{
    public partial class commentPage : PhoneApplicationPage
    {

        IsolatedStorageSettings trkCom = IsolatedStorageSettings.ApplicationSettings;
        List<Comment> commentsList = new List<Comment>();
        BitmapImage im;
        
        public commentPage()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            List<Comment> commentsList = new List<Comment>();

            commentsList.Add(new Comment("secret fan","wooooooooow! yahudia it's a cool track",null));

            try 
            { 
                im = (BitmapImage)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["pic"]; 
            }
            catch {};

            if (trkCom.Contains("comment"))
                commentsList.Add(new Comment((String)trkCom["username"], (String)trkCom["comment"], im));
            
            CommList.ItemsSource = commentsList;

        }

        public class Comment
        {

            public String Username { get; set; }
            public String CommText { get; set; }
            public BitmapImage Picture { get; set; }

            public Comment(String username, String text, BitmapImage picture)
            {
                this.Username = username;
                this.CommText = text;
                this.Picture = picture;
            }

        }

        private void PhoneApplicationPage_Unloaded(object sender, RoutedEventArgs e)
        {
            trkCom.Remove("comment");
            trkCom.Remove("name");
        }

    }

}
